package com.southwind.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.southwind.entity.Account;
import com.southwind.servise.AccountService;

@RestController
@RequestMapping("/account")
public class AccountController {

	@Autowired
	AccountService serice;

	// 新增
	@RequestMapping("/save")
	public int save(@RequestBody Account account) {
		return serice.save(account);

	}

	// 修改
	@RequestMapping("/update")
	public int update(@RequestBody Account account) {
		return serice.update(account);

	}

	// 根据编号删除
	@RequestMapping("/deleteById/{id}")
	public int deleteById(@PathVariable("id") long id) {
		return serice.deleteById(id);

	}

	// 查询所有的account
	@RequestMapping("/findAll")
	public List<Account> findAll() {
		return serice.findAll();

	}

	// 根据编号查询
	@RequestMapping("/findById/{id}")
	public Account findById(@PathVariable("id") long id) {
		return serice.findById(id);

	}
	
	//根据编号查姓名
			@RequestMapping("/findNameById/{id}")
			public String findNameById(@PathVariable("id") long id) {
				return serice.findNameById(id);
				
			}

}
